﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    Datacon dataconn = new Datacon();
    protected void Button1_Click(object sender, EventArgs e)
    {
        HttpCookieCollection checkCode = Request.Cookies;
        //string a = TextBox7.Text;
        //string b = checkCode["CheckCode"].Value;
        if (TextBox1.Text == "" || TextBox2.Text == "")
        {
            Response.Write("<script>alert('请输入完整！')</script>");
            Response.Write("<script language=javascript>window.location.href='Index.aspx'</script>");

        }
        //else if (!a.Equals(b, StringComparison.OrdinalIgnoreCase))
        //{
        //    Response.Write("<script>alert('验证码有误！')</script>");
        //    Response.Write("<script language=javascript>window.location.href='Index.aspx'</script>");

        //}
        else
        {
            SqlConnection cn = dataconn.getcon();
            cn.Open();
            SqlCommand com = cn.CreateCommand();

            com.CommandText = "select count(*) from Admin where  name='" + TextBox1.Text + "'and PWD='" + TextBox2.Text + "'";
            int count1 = Convert.ToInt32(com.ExecuteScalar());
            if (count1 > 0)
            {
                Session["ID"] = TextBox1.Text;
                com.CommandText = "select zwname from Admin where  name='" + TextBox1.Text + "'and PWD='" + TextBox2.Text + "'";
                Session["name"] = com.ExecuteScalar();
                cn.Close();

                Response.Redirect("fenlei.aspx");
            }
            else
            {
                cn.Close();
                Response.Write("<script language=javascript>alert('用户名或密码错误！')</script>");


            }

        }
    }
}